package ru.susu.algebra.partition.comparators;

import java.util.Comparator;

import ru.susu.algebra.chartable.constructor.AlternatingCharTableUtil;
import ru.susu.algebra.partition.Partition;

/**
 * @author akargapolov
 * @since: 12.03.2009
 */
public class AlternatingByCharDegreeComparator implements Comparator<Partition>
{
	public static final AlternatingByCharDegreeComparator INSTANCE = new AlternatingByCharDegreeComparator();

	@Override
	public int compare(Partition p1, Partition p2)
	{
		try
		{
			return AlternatingCharTableUtil.calcAlternatingDegree(p1).compareTo(
					AlternatingCharTableUtil.calcAlternatingDegree(p2));
		}
		catch (Exception e)
		{
			// TODO anything
			return 0;
		}
	}

}
